home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / MATH / NRPAS13 / CHEBEV.DEM < prev    next >
Text File  |  1991-04-29  |  912b  |  44 lines

  1. PROGRAM d5r5(input,output);
  2. (* driver for routine CHEBEV *)
  3. LABEL 10,99;
  4. CONST
  5.    nval=40;
  6.    pio2=1.5707963;
  7. TYPE
  8.    glcarray=ARRAY [1..nval] OF real;
  9. VAR
  10.    a,b,x : real;
  11.    i,mval : integer;
  12.    c : glcarray;
  13.  
  14. FUNCTION func(x: real): real;
  15. BEGIN
  16.    func := sqr(x)*(sqr(x)-2.0)*sin(x)
  17. END;
  18.  
  19. (*$I MODFILE.PAS *)
  20. (*$I CHEBFT.PAS *)
  21.  
  22. (*$I CHEBEV.PAS *)
  23.  
  24. BEGIN
  25.    a := -pio2;
  26.    b := pio2;
  27.    chebft(a,b,c,nval);
  28. (* test chebyshev evaluation routine *)
  29. 10:   writeln;
  30.    writeln('How many terms in Chebyshev evaluation?');
  31.    write('Enter n between 6 and ',nval:2,
  32.          '. (n := 0 to end).  ');
  33.    readln(mval);
  34.    IF ((mval <= 0) OR (mval > nval)) THEN GOTO 99;
  35.    writeln;
  36.    writeln('x':9,'actual':14,'chebyshev fit':16);
  37.    FOR i := -8 to 8 DO BEGIN
  38.       x := i*pio2/10.0;
  39.       writeln(x:12:6,func(x):12:6,chebev(a,b,c,mval,x):12:6)
  40.    END;
  41.    GOTO 10;
  42. 99:
  43. END.
  44.